package chapter10.practice10;

import chapter10.practice9.SimpleInterface;

/**
 * 在某个方法的一个作用域里面定义内部类
 * Created by yangliwei on 2017/10/21.
 */
public class SimpleClass {
    int a = 0;

    public SimpleInterface getSimpleInterface() {

        SimpleInterface simpleInterface = null;
        if (a == 0) {
            class Sub implements SimpleInterface {

                @Override
                public void f() {
                    System.out.println("I'm called");
                }
            }
            simpleInterface = new Sub();
        }
        return simpleInterface;
    }

    public static void main(String[] args) {
        chapter10.practice9.SimpleClass simpleClass = new chapter10.practice9.SimpleClass();
        SimpleInterface simpleInterface = simpleClass.getSimpleInterface();
        simpleInterface.f();

    }
}
